﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipSys.Business;
using VipSys.DataLayer;
using VipSys.SystemEntity;
using VipSys.Common;

namespace VipSys.website
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string szUserName = this.txtTel.Text.Trim();
            if (string.IsNullOrEmpty(szUserName))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入登录所需的手机号码!')</script>");
                return;
            }
            string szPwd = this.txtPwd.Text.Trim();
            if (string.IsNullOrEmpty(szPwd))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入密码!')</script>");
                return;
            }
            User user = new User();
            User query = new User();
            query.Tel = szUserName;
            query.PassWord = szPwd;
            short shRet = UserAccess.Instance.GetUser(query, ref user);
            if (shRet != SystemData.ReturnValue.OK)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('账号密码不对!')</script>");
                return;
               
            }
            SysAccount account = new SysAccount();
            account.ID = user.ID;
            account.Name = user.Name;
            account.RoleType = "会员";
            account.Room = user.Room;
            account.Password = user.PassWord;
            account.Hotel = user.Hotel;
            SystemParam.Instance.SysAccount = account;
            Response.Redirect("SubExamPlace.aspx");
        }
    }
}